//
//  SNAddCommentsView.m
//  app
//
//  Created by 王少宁 on 15/5/15.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "SNAddCommentsView.h"

@interface SNAddCommentsView ()
@property (nonatomic, retain) UIImageView * goodsImageView;
@property (nonatomic, retain) UILabel * titleLabel;
@property (nonatomic, retain) UILabel * moneyLabel;
@property (nonatomic, retain) UILabel * countLabel;
@end

@implementation SNAddCommentsView

- (instancetype)initWithFrame:(CGRect)frame model:(SNOrderFormDetailGoodsModel *)model type:(GoodsViewType)type
{
    if ([super initWithFrame:frame]) {
        [self createViewWithModel:model type:type viewHeight:frame.size.height ];
    }
    
    return self;
}

- (void)createViewWithModel:(SNOrderFormDetailGoodsModel *)model type:(GoodsViewType)type viewHeight:(CGFloat)height
{
    _goodsImageView = [[UIImageView alloc] initWithFrame:CGRectMake(UF(24), 10, 64, 64)];
    _goodsImageView.layer.borderWidth = UP(1);
    _goodsImageView.layer.borderColor = [XCommon hexStringToColor:kColor_gray_line].CGColor;
    [_goodsImageView sd_setImageWithURL:[NSURL URLWithString:model.title_pic]];
    [self addSubview:_goodsImageView];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.numberOfLines = 0;
    _titleLabel.font = JKAppGlobleFontSmallTagText;
    _titleLabel.textColor = [XCommon hexStringToColor:kColor_l_light_gray_text];
    CGFloat titleLabelHeight = [XCommon heightForString:model.product_title fontSize:13 andWidth:SCREEN_WIDTH-UF(24)-10-_goodsImageView.ufo.xx];
    _titleLabel.frame = CGRectOf([_goodsImageView.ufo fx:1.0 ox:10 fy:0],
                                 [self.ubo ow:SCREEN_WIDTH - _goodsImageView.ubo.width - 30 oh:titleLabelHeight]);
    _titleLabel.text = model.product_title;
    [self addSubview:_titleLabel];
    
    _moneyLabel = CREATE_WITH_FRAME_OF(UILabel, [_titleLabel.ufo fx:0 oy:_goodsImageView.ufo.yy-30],
                                       [self.ubo ow:100 oh:20]);
    _moneyLabel.font = [UIFont boldSystemFontOfSize:13];
    _moneyLabel.textColor = [XCommon hexStringToColor:kColor_l_light_gray_text];
    _moneyLabel.text = [NSString stringWithFormat:@"￥%@",model.price];
    [self addSubview:_moneyLabel];
    
    _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-UF(24)-60, _moneyLabel.ufo.y, 60, 20)];
    _countLabel.textAlignment = NSTextAlignmentRight;
    _countLabel.font = JKAppGlobleFontSmallTagText;
    _countLabel.text = [NSString stringWithFormat:@"×%@",model.product_num];
    [self addSubview:_countLabel];
}

- (void)drawRect:(CGRect)rect
{
    [self drawBackground:rect color:[XCommon hexStringToColor:kColor_m_light_gray_background]];
    [self drawSeperatorLineLeft:0 right:0];
}

@end









